package com.tomowork.entity;



import com.fasterxml.jackson.annotation.JsonFormat;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
@Cacheable(value = true)
@Entity
@Table(name="emp")
public class Emp implements Serializable{
    private Integer empno ;//雇员编号
    @NotNull(message = "雇员姓名不能为空")
    private String ename ; //雇员姓名

    private Date createtime ;
    private Date updatetime ;
    //雇员所属的部门
    private Dept dept = new Dept() ;

    public Emp(){}
    public Emp(Integer empno,String ename){
        this.empno = empno ;
        this.ename = ename ;
    }
    @Id
    @Column(name="empno",unique = true,nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Integer getEmpno() {
        return empno;
    }

    public void setEmpno(Integer empno) {
        this.empno = empno;
    }

    public String getEname() {
        return ename;
    }

    public void setEname(String ename) {
        this.ename = ename;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+12",locale = "zh")
    public Date getCreatetime() {
        return createtime;
    }

    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+12",locale = "zh")
    public Date getUpdatetime() {
        return updatetime;
    }

    public void setUpdatetime(Date updatetime) {
        this.updatetime = updatetime;
    }

    @ManyToOne(fetch = FetchType.EAGER) //多对一
    @JoinColumn(name = "deptno")
    public Dept getDept() {
        return dept;
    }
    public void setDept(Dept dept) {
        this.dept = dept;
    }
}
